/*
  mdsuspend.c - nastroj na odpojenie programu MDemon od mobilu
*/
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>

#include "../libmdemonapl/mdemonapl.h"

int main(int argc, char *argv[]){
  
  char *response;
  int fd;
  
  fd = mdconnect_and_auth();
  if (fd < 0)
  {
    perror("suspend sa nepodaril:");
    return 1;
  }
  
  if (mdsend_command_and_get_response(fd, "SUSPEND\n", &response) == -1)
  {
    perror("SUSPEND failed:");
    return 1;
  }
  else if (strstr(response, "200") == NULL)
  {
    printf("%s", response);
    //syslog(LOG_ERR, "%s", response);
    return 1;
  }
  else
  {
    printf("%s", response);
    //syslog(LOG_INFO, "%s", response);
    return  0;
  }
}

